package com.example.lenovo.demo.view;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.DrawerLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.lenovo.demo.R;
import com.example.lenovo.demo.presenter.HomeFgPresenter;
import com.example.lenovo.demo.view.customview.MyRecyclerView;
import com.example.lenovo.demo.view.ifgview.IHomeFragment;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

/**
 * Created by Lenovo on 2017/1/5.
 */
@ContentView(R.layout.fragment_lv)
public class HomeFragment extends Fragment implements IHomeFragment {
    private HomeFgPresenter homeFgPresenter;
    private View view;

    private ProgressDialog progressDialog;
    @ViewInject(R.id.myrv)
    private MyRecyclerView recyclerView;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view= x.view().inject(this,inflater,container);

        init();
        homeFgPresenter.initData();
        return view;
    }
    /**实例化P层和进度条
     * */
    private void init() {
        //实例化P层的类
        homeFgPresenter =new HomeFgPresenter(this);
        progressDialog=new ProgressDialog(getActivity());
        progressDialog.setTitle("提示");
        progressDialog.setMessage("正在加载...");
        progressDialog.setCancelable(true);
    }




    @Override
    public MyRecyclerView getMyRv() {
        return recyclerView;
    }

    @Override
    public Context getFgContext() {
        return getActivity();
    }

    @Override
    public FragmentManager getFgManager() {
        return getFragmentManager();
    }

    @Override
    public HomeFragment getHomeFragment() {
        return HomeFragment.this;
    }

    @Override
    public ProgressDialog getProgressDialog() {
        return progressDialog;
    }


}
